<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('字典树选择')" />
	<th:block th:include="include :: ztree-css" />
</head>
<style>
	body{height:auto;font-family: "Microsoft YaHei";}
	button{font-family: "SimSun","Helvetica Neue",Helvetica,Arial;}
</style>
<body class="hold-transition box box-main">
	<input id="treeId"   type="hidden" />
	<input id="userId" type="hidden" />
	<input id="userName" type="hidden" />
	<input id="empName" type="hidden" />
	<input id="userNameShow" type="hidden" />
	<input id="phonenumber" type="hidden" />
	<input id="email" type="hidden" />


	<input id="deptId" type="hidden" />
	<input id="deptName" type="hidden" />
	<input id="postId" type="hidden" />
	<input id="postName" type="hidden" />
	<input id="nonManagerDate" type="hidden" />


	<div class="wrapper"><div class="treeShowHideButton" onclick="$.tree.toggleSearch();">
		<label id="btnShow" title="显示搜索" style="display:none;">︾</label>
		<label id="btnHide" title="隐藏搜索">︽</label>
	</div>
	<div class="treeSearchInput" id="search">
		<label for="keyword">关键字：</label><input type="text" class="empty" id="keyword" maxlength="50">
		<button class="btn" id="btn" onclick="$.tree.searchNode()"> 搜索 </button>
	</div>
	<div id="tree" class="ztree treeselect"></div>
	</div>
	<th:block th:include="include :: footer" />
	<th:block th:include="include :: ztree-js" />
	<script th:inline="javascript">
		$(function() {

			var url = ctx + "system/user/treeData";
			var options = {
		        url: url,
				expandLevel: 1,
                onCheck : zOnClick,
                beforeCheck : function(treeId, treeNode) {
		            debugger
                    if (treeNode.children) {
                        layer.msg('不可选择部门节点');
                        return false;
                    }
                    if (treeNode.id == null) {
                        layer.msg('不可选择部门节点');
                        return false;
                    }
                },
                check : {
                    enable: true,
                    chkStyle: "radio"
				},
                data: {
                    key: {
                        title: "title"         // 节点数据保存节点提示信息的属性名称
                    },
                    simpleData: {

                        enable: true, //设置是否启用简单数据格式（zTree支持标准数据格式跟简单数据格式，上面例子中是标准数据格式）

                        idKey: "deptId", //设置启用简单数据格式时id对应的属性名称

                        pidKey: "pId" //设置启用简单数据格式时parentId对应的属性名称,ztree根据id及pid层级关系构建树结构

                    }
                }
		    };
			$.tree.init(options);
		});
		
		function zOnClick(event, treeId, treeNode) {
		    $("#userId").val(treeNode.id);
		    $("#userName").val(treeNode.title);
		    $("#userNameShow").val(treeNode.name);
			$("#empName").val(treeNode.empName);

            $("#phonenumber").val(treeNode.phonenumber);
            $("#email").val(treeNode.email);

            $.get(ctx + "system/user/selectUserById?userId="+treeNode.id, function(result) {
                if (result.code == web_status.SUCCESS) {
                    $("#postId").val(result.data.sysPostVO.postId);
                    $("#postName").val(result.data.sysPostVO.postName);
                    $("#deptId").val(result.data.dept.deptId);
                    $("#deptName").val(result.data.dept.deptName);
                    $("#nonManagerDate").val(result.data.nonManagerDateVO);
                }
            });



		}
	</script>
</body>
</html>
